package com.jgp.control;

import com.jgp.Exception.BusinessException;
import com.jgp.Exception.SystemException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
//处理异常的类
@RestControllerAdvice
public class ProjectExceptionAdvice {
    @ExceptionHandler(BusinessException.class)
    public Result deBusinessException(BusinessException ex){
        System.out.println("异常哪里跑");
        return new Result(ex.getCode(),null,ex.getMessage());
    }
    @ExceptionHandler(SystemException.class)
    public Result deSystemException(SystemException ex){
        System.out.println("异常哪里跑");
        return new Result(ex.getCode(),null,ex.getMessage());
    }
    @ExceptionHandler(Exception.class)
    public Result deException(Exception ex){
        System.out.println("异常哪里跑");
        return new Result(Code.SYS_UNKNOW_ERR,null,"系统繁忙，请联系管理员");
    }
}
